﻿#include "mediasocket.h"
#include "mediaserver.h"

MediaSocket::MediaSocket(QObject *parent)
{
    is = false;
    connect(this,&QTcpSocket::readyRead,this,[=](){
        auto data = readAll();
        if(!is)
        {
            id = QString(data);
            is = true;
        }
        else
        {
            //向接收者转发数据
            MediaServer::getInstance().tranData(data,id);
        }
    });
}

QString MediaSocket::getId()
{
    return id;
}
